package com.xsm.internet;
import java.util.List;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;

import android.util.Log;

public class PostMessage {
	List<NameValuePair> params;
	String urlString=new ConnectUrl().url;
	String result="-1";
   public PostMessage(List<NameValuePair> params){
	this.params=params;
	try{
		HttpPost request=new HttpPost(urlString);
       HttpParams httpParameters = new BasicHttpParams();  
	    HttpConnectionParams.setConnectionTimeout(httpParameters,5000);  
       request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
         HttpClient client = new DefaultHttpClient(httpParameters);
	 HttpResponse response; 
	 response=client.execute(request); 
	    if(response.getStatusLine().getStatusCode()==200)
        {  
            result = EntityUtils.toString(response.getEntity()).trim();
        }
	}catch (Exception e){
		Log.d("my", e+"");
		 result="-1";
	}	
	}
   
   public String getResult(){
	   return result;
   }
}